import {defineStore} from 'pinia'

const useStat = defineStore("stat", {
    state: () => ({
        dataList: [],
        questionList: [],
        total: 0
    }),
    getters: {},
    actions: {
        updateList(value){
            this.questionList = value
        },
        updateStar(_id) {
            let index = this.questionList.findIndex(i => i._id === _id)
            if (index !== -1) {
                this.questionList[index].isStar = !this.questionList[index].isStar
            }
        },
        deleteItem(_id){
            let index = this.questionList.findIndex(i => i._id === _id)
            if (index !== -1) {
                this.questionList.splice(index, 1)
            }
        }
    }
})
export default useStat
